package com.boot.security.server.dao.mffl;

import com.boot.security.server.model.mffl.MfflSystemMessages;
import com.boot.security.server.model.mffl.Vo.MfflSystemMessagesCountVo;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface MfflSystemMessagesDao {

    @Select("select * from mffl_system_messages t where t.id = #{id}")
    MfflSystemMessages getById(Long id);

    @Delete("delete from mffl_system_messages where id = #{id}")
    int delete(Long id);

    int update(MfflSystemMessages mfflSystemMessages);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into mffl_system_messages(user_id,content, type, message_id, createTime, updateTime) values(#{userId}, #{content}, #{type}, #{messageId}, now(),now())")
    int save(MfflSystemMessages mfflSystemMessages);
    
    int count(@Param("params") Map<String, Object> params);

    List<MfflSystemMessages> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    List<MfflSystemMessages> getSystemMessages(@Param("userId") Long id);

    @Update("update mffl_system_messages set status = 0 where user_id = #{userId} ")
    int updateMessageStatusByUserIdAll(@Param("userId") Long userId);
    @Update("update mffl_system_messages set status = 0 where user_id = #{userId} and id = #{id}")
    int updateMessageStatusById(@Param("id") long id,@Param("userId") Long userId);

    MfflSystemMessagesCountVo getSystemMessagesCount(@Param("userId") Long id);
}
